const searchBox = {
    v_jmp_dom: document.createElement('a'),
    search_input_dom: document.querySelector('.input-dom > input'),
    search_btn_dom: document.querySelector('.search-btn'),
    setSearchBox() {
        // 绑定用户焦点在输入框时，按下回车键时触发搜索事件
        this.search_input_dom.addEventListener('keydown', (e) => {
            if (e.key === 'Enter') {
                this.search();
            }
        });
        // 点击搜索按钮的时候触发搜索事件
        this.search_btn_dom.addEventListener('click', (e) => {
            this.search();
        });
    },
    search() {
        // 搜索函数
        let search_str = this.search_input_dom.value;
        let jmp = this.v_jmp_dom;
        jmp.href = `https://www.baidu.com/s?wd=${search_str}`;
        jmp.target = '_blank';
        jmp.click();
    }
}

